const responseUtil = {
    success: (data = null, message = '操作成功') => {
        return {
            code: 1,
            message,
            data
        };
    },
    error: (message = '操作失败', code = 0) => {
        return {
            code,
            message
        };
    }
};

const errorResponse = (res, message, statusCode = 500) => {
    return res.status(statusCode).json({
        code: 0,
        message
    });
};

module.exports = {
    ...responseUtil,
    errorResponse
};